<?php
require_once(dirname(__FILE__)."/init.php");
$sql = "select id,ip from openStatistics where country='0' order by id desc group by ip limit 0,10";
$result = $GLOBALS['db']->dbfetchAll($sql);
$clients = new client();
foreach($result as $key=>$value){
	$arr = $clients->ip_lookup($value['ip']);
	$sql = "update openStatistics set country='".$arr->country."',province='".$arr->province."',city='".$arr->city."' where ip='".$value['ip']."'";
	$GLOBALS['db']->dbquery($sql);
}

$sql = "select id,ip from clickTrack where country='0' order by id desc group by ip limit 0,30";
$result = $GLOBALS['db']->dbfetchAll($sql);
foreach($result as $key=>$value){
	$arr = $clients->ip_lookup($value['ip']);
	$sql = "update clickTrack set country='".$arr->country."',province='".$arr->province."',city='".$arr->city."' where ip='".$value['ip']."'";
	$GLOBALS['db']->dbquery($sql);
}
?>